from PyQt5.QtQuick import QQuickView
from PyQt5 import  QtGui, QtWidgets, QtCore
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5 import QtQml,QtQuick
import sys
import random

from handlers.httpclient import HttpClient
from handlers.counters import CounterHandler#win运行注释掉
from handlers.network import Network

from PyQt5.QtCore import Qt
Qt.AlignmentFlag

app = QtWidgets.QApplication(sys.argv)
# engine = QtQml.QQmlApplicationEngine(QUrl('Main.qml')) # 显示window界面
engine = QtQml.QQmlApplicationEngine(QUrl('/home/pi/Bookshelf/counter_XZ/counter_qml/Main.qml')) # 显示window界面

http = HttpClient()
http.login()

network = Network()
network.startCheck()
counter = CounterHandler() # win运行注释掉

engine.rootContext().setContextProperty('gHttp', http)
engine.rootContext().setContextProperty("gCounter", counter) # win运行注释掉
engine.rootContext().setContextProperty("gNetwork", network)

engine.quit.connect(app.quit)
sys.exit(app.exec_())